package com.cek.tdrive;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.coyote.Request;

import com.cek.tdrive.database.DbManager;

/**
 * Servlet implementation class SetAlert
 */
@WebServlet("/SetAlert")
public class SetAlert extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public SetAlert() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String lat=request.getParameter("lat");
		String longt=request.getParameter("long");
		double lat1=0;
		double long1=0;
		if(lat!=null&&longt!=null){
			lat1=Double.parseDouble(lat);
			long1=Double.parseDouble(longt);
			
			
		}
		String time=request.getParameter("time");
		 long alertTime=0; 
		   if(time!=null){
			   alertTime = Long.parseLong(time);
			   
		   }
			
		String alertdata=request.getParameter("alert");
		String des=request.getParameter("des");
		
		if(alertdata!=null) {
			DbManager.getInstance().saveAlert(lat1, long1, alertTime, alertdata, des);
		}
		
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

}
